<template>
	<my-page title="表单监控">
		<my-page ref="mypage" v-model="formList" :height="system.screenHeight - system.statusBarHeight - 44" @load-data="loadData">
			<template slot="content">
				<view v-for="(item,index) in formList" :key="item.id" class="relative bg-white m-4 p-4 last:mb-0 shadow-lg rounded-xl  active:bg-gray-100 flex" @click="openDetail(item)">
				    <view class="flex-1 flex flex-col">
				        <view class="flex-1">
				            <view class="zx-ellipsis">
				                <p>{{item.name}}</p>
				            </view>
				            <view class="text-gray-500 text-sm py-2">
				                <view>表单类型：{{item.typeName}}</view>
				                <view>创建时间：{{$util.getFormatDate(item.createTime, 'yyyy-0m-0d')}}</view>
				                <view></view>
				            </view>
				        </view>
				        <view class=" text-sm flex">
				            <view class="flex-1">
				                由 <text class="font-bold">{{item.createUsername}}</text> 创建
				            </view>
				            <view>
				            <!-- 表单状态 draft 草稿,approve 审批中,complete 完成,pass 通过,notPass 不通过 -->
				                <text v-if="item.status == 'draft'" class="text-indigo-600">草稿</text>
				                <text v-else-if="item.status == 'approve'" class="text-yellow-500">审批中</text>
				                <text v-else-if="item.status == 'complete'" class="text-blue-500">完成</text>
				                <text v-else-if="item.status == 'pass'" class="text-red-500">通过</text>
				                <text v-else-if="item.status == 'notPass'" class="text-red-600">不通过</text>
				            </view>
				        </view>
				    </view>
				</view>
			</template>
		</my-page>
	</my-page>
</template>

<script>
	import {mapState} from 'vuex'
	import MyPage from '@/components/my_page.vue'
	import NavHeader from '@/components/nav_header.vue'
	import {getDeptFormHistoryList} from '@/interface/junchuang/form'
	export default {
		name: 'formAdminList',
		components: { NavHeader, MyPage },
		data() {
			return {
				formList: [],
				params: {}
			}
		},
		computed: {
			...mapState({
				system: state => state.system
			})
		},
		methods: {
			searchList(page, success, error){
			    Object.assign(this.params,page);
			    getDeptFormHistoryList(this.params).then(res => success(res)).catch(err=> error(err));
			},
			openDetail(item){
			    this.$util.myNavigateTo('/form/detail?formId='+item.formId+'&businessId='+item.id+'&formCode='+item.formCode);
			},
		},
    activated(){
        // 移除当前页的“子级”组件缓存
        // this.$utils.removeChildCache(this, '/workFlow/form')
    }
	}
</script>

<style>

</style>
